package com.whw.fy.controller;


import com.sun.org.apache.bcel.internal.generic.NEW;
import com.sun.org.apache.regexp.internal.RE;
import com.whw.fy.entity.Message;
import com.whw.fy.entity.ParentComm;
import com.whw.fy.entity.TeachSummary;
import com.whw.fy.service.TeachSummaryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

@Api(tags = "教学总结模块")
@RestController
@RequestMapping("/api/teachsummary")
public class TeachSummaryController {

    @Resource
    TeachSummaryService teachSummaryService;

    @ApiOperation(value = "添加教学总结记录")
    @PostMapping("/insert")
    public Message insert(TeachSummary teachSummary)throws ParseException {
       teachSummary.setTeachCreatetime(new Date());
        return teachSummaryService.insertSelective(teachSummary);
    }

    @ApiOperation(value = "删除教学总结记录")
    @DeleteMapping("/")
    public Message delete(int teachSummaryId) {
        return teachSummaryService.deleteByPrimaryKey(teachSummaryId);
    }

    @ApiOperation(value = "修改教学总结记录")
    @PutMapping("/")
    public Message update(TeachSummary teachSummary){
        return teachSummaryService.updateByPrimaryKeySelective(teachSummary);
    }

    @ApiOperation(value = "根据教学总结id查找教学总结记录")
    @GetMapping("/select")
    public Message selectByPrimaryKey(int teachSummaryId){
        return teachSummaryService.selectByPrimaryKey(teachSummaryId);
    }

    @ApiOperation(value = "获得所有教学总结记录")
    @GetMapping("/all")
    public Message selectAll(){
        return teachSummaryService.selectAll();
    }

    @ApiOperation(value = "根据学生id获得教学总结")
    @GetMapping("/studentId/all")
    public Message selectByStudentId(int studentId){
        return teachSummaryService.selectByStudentId(studentId);
    }

    @ApiOperation(value = "修改教学总结状态")
    @PutMapping("/status")
    public Message updateStatus(int status,int teachId){
        return teachSummaryService.updateStatus(status, teachId);
    }

    @ApiOperation(value = "教学主管批复")
    @PostMapping("/update/replyTeachingDirector")
    public Message updateReplyTeachingDirector(TeachSummary teachSummary){
        teachSummary.setTeachReplyTeachingDirectorTime(new Date());
        return teachSummaryService.updateReplyTeachingDirector(teachSummary);
    }

    @ApiOperation(value = "主责老师批复")
    @PostMapping("/update/replyPrincipalTeacher")
    public Message updateReplyPrincipalTeacher(TeachSummary teachSummary){
        teachSummary.setTeachReplyPrincipalTeacherTime(new Date());
        return teachSummaryService.updateReplyPrincipalTeacher(teachSummary);
    }

    @ApiOperation(value = "小程序获得该学生最新的教学总结")
    @GetMapping("/newone")
    public Message selectNewOneByStudentId(int studentId){
        return teachSummaryService.selectNewOneByStudentId(studentId);
    }


    @ApiOperation(value = "根据医疗主管id查询旗下所有教学总结")
    @GetMapping("/all/MedicalDirectorIdJurisdictionZero")
    public Message selectallByMedicalDirectorIdJurisdictionZero(int staffId){
        return teachSummaryService.selectallByMedicalDirectorIdJurisdictionZero(staffId);
    }

    @ApiOperation(value = "根据授课老师id查询旗下所有教学总结")
    @GetMapping("/all/TeacherIdJurisdictionEight")
    public Message selectallByTeacherIdJurisdictionEight(int staffId){
        return teachSummaryService.selectallByTeacherIdJurisdictionEight(staffId);
    }

    @ApiOperation(value = "根据教学主管id查询旗下所有教学总结")
    @GetMapping("/all/TeachingDirectorJurisdictionSix")
    public Message selectallByTeachingDirectorJurisdictionSix(int staffId){
        return teachSummaryService.selectallByTeachingDirectorJurisdictionSix(staffId);
    }

    @ApiOperation(value = "根据主责老师id查询旗下所有教学总结")
    @GetMapping("/all/principalTeacherJurisdictionSeven")
    public Message selectallByprincipalTeacherJurisdictionSeven(int staffId){
        return teachSummaryService.selectallByprincipalTeacherJurisdictionSeven(staffId);
    }
}
